﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace AppFuscator
{
    [Obfuscation]
    public enum RenameScheme
    {
        LatinAlphabeticalOrder,
        OverloadingLatinAlphabeticalOrder,
        Guid,
        Unprintable,
        OneChar
    }

    public static class RenameSchemeConverter
    {
        private static Dictionary<RenameScheme, string> renamer = new Dictionary<RenameScheme, string>();

        static RenameSchemeConverter()
        {
            renamer.Add(RenameScheme.LatinAlphabeticalOrder, "Latin letters");
            renamer.Add(RenameScheme.OverloadingLatinAlphabeticalOrder, "Latin letters (overloading)");
            renamer.Add(RenameScheme.Guid, "GUIDs");
            renamer.Add(RenameScheme.Unprintable, "Unprinatable");
            renamer.Add(RenameScheme.OneChar, "Repeated char");
        }

        public static RenameScheme Convert(string name)
        {
            foreach (var it in renamer)
            {
                if (it.Value.Equals(name, StringComparison.OrdinalIgnoreCase))
                    return it.Key;
            }

            throw new ArgumentOutOfRangeException();
        }

        public static string Convert(RenameScheme scheme)
        {
            foreach (var it in renamer)
            {
                if (it.Key == scheme)
                    return it.Value;
            }

            throw new ArgumentOutOfRangeException();
        }

        public static IEnumerable<string> AllNames
        {
            get
            {
                foreach (var it in renamer)
                    yield return it.Value;
            }
        }
    }
}
